JavaScript Today's Link

This page contains a JavaScript that selects a different URL for each day of the week

Please note that JavaScript is currently only available in Netscape Navigator 2.0 or higher.
Do not assume that all in your audience are using a JavaScript enabled browser.


This JavaScript lets you present a different link to a different document URL for each day of the week.

You can use this to direct your readers to a different site each day of the week, or if you run a daily newsletter you can use it to let readers to go to a specific file depending on the day of the week.

The script is named GetTodaysURL and it is placed in the HEAD section of the HTML document. The script is executed by clicking on a link containing a call to GetTodaysURL(). Also note the custom text in Netscape's status area.

Example of this script picking todays page. Another page will be displayed tomorrow.

Internet Explorer Warning!
Internet Explorer support for JavaScript (called JScript, for obvious reasons ;-) is not as complete as Netscape's implementation, so the script above will give an error message in version 3.0 of MS Internet Explorer for Windows. The 3.0 beta 1 version of Internet Explorer for MacOS doesn't seem to support JScript at all.

View an example of a dynamic script that works around this bug in the Random Link Example.

How to use:
Replace the filenames inside the script with your own URLs and edit this page contents inside the <BODY> section. (You can also copy the entire script to one of your existing pages).

function GetTodaysURL() { // Put relative or full URL's in the strings below // First line is returned on Mondays, second on Tuesdays ... // ... and the seventh on Sundays var locationlist = new URLList ( "groucho.html", // Monday "harpo.html", // Tuesday "zeppo.html", "chico.html", "harpo.html", "groucho.html", "chico.html" // Sunday );

Use code similar to this to let the user execute the script:

<A HREF="" onClick="this.href=GetTodaysURL()" onMouseOver="window.status='Page of the day!'; return true">Todays page</A>